#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
ll power[100];
void solve()
{
    ll n, kk,k;
    cin >> n >> k;
    vector<ll> a(n+1),sum(n+1,0);
    map<ll, ll> mp;
    for (ll i = 1; i <= n;i++)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        mp[sum[i] % k]++;
    }
    ll ans = 0;
    
    for(auto [x,y] : mp)
    if(y>=2)
    {
        ans += (y - 1) * y / 2;
    }
    cout << ans;
}
int main()
{
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
